const path = require('path');
function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  lintOnSave: true,
  configureWebpack: config => {

    let commonConfig = {
      resolve: {
        alias: {
          "styles": resolve("src/assets/styles")
        }
      }
    };

    let productionConfig = {

    };

    let devConfig = {
      devServer: {
        open: true,
        proxy: {
          '/api': {
            target: 'http://localhost:8080',
            pathRewrite: {'^/api' : '/mock'}
          }
        }
      },
    };

    if (process.env.NODE_ENV === 'production') {
      // 为生产环境修改配置...
      return Object.assign(productionConfig, commonConfig);
    } else {
      // 为开发环境修改配置...
      return Object.assign(devConfig, commonConfig);
    }
  }
};
